<template>
  <div class="box">
    <el-table :data="dataList"  height="calc(80vh - 325px)"  @selection-change="selectChange"  >
      <el-table-column label="追溯码/批次号" width="600">
        <template #default="scope">
          <el-input
              type="textarea"
              :rows="2"
              placeholder="请输入追溯码或者批次号"
              v-model.trim="scope.row.traceBackNo"
              maxlength="65"
              show-word-limit
          >
          </el-input>
        </template>
      </el-table-column>
<!--      <el-table-column label="箱号" width="160" prop="boxNo"></el-table-column>-->
<!--      <el-table-column label="物料" width="120" prop="materialNo"></el-table-column>-->
      <el-table-column width="160" label="操作">
        <template #default="scope">
          <el-button type="success"  size="small" @click="selectRow(scope.$index, scope.row)">查看</el-button>
<!--          <el-button type="danger"  size="small" @click="deleteRow(scope.$index, scope.row)">删除</el-button>-->
        </template>

      </el-table-column>
    </el-table>

    <div>
      <el-table :data="infoList"  height="calc(100vh - 325px)"  >
        <el-table-column label="No." width="60" align="right" type="index"></el-table-column>
        <el-table-column label="单据编号" width="180" prop="billNo"></el-table-column>
        <el-table-column label="操作人" width="120" prop="createUserName"></el-table-column>
        <el-table-column label="单据日期" width="180" prop="createTime"></el-table-column>
        <el-table-column label="物料编码" width="120" prop="materialNo"></el-table-column>
        <el-table-column label="物料名称" width="120" prop="materialName"></el-table-column>
        <el-table-column label="箱号" width="160" prop="boxNo"></el-table-column>
        <el-table-column label="任务单号" width="180" prop="taskBillNo"></el-table-column>


      </el-table>
    </div>
  </div>

</template>

<script>

export default {
  name: "selectTraceCode",
  data() {
    return {
      loading:false,
      dataList:[{traceBackNo:"",boxNo:"",materialNo:"",}],
      infoList:[]
    }
  },
  methods:{
    async selectRow(index,row){
      this.loading = true
      let param = {traceBackNo : this.dataList[index].traceBackNo}
      try {
        let res = await this.callApi('get_serial_up',param)
        if (!res.res) return
        this.dataList[index].boxNo = res.data.boxNo
        this.dataList[index].materialNo = res.data.materialNo
        this.infoList = res.data
      }finally {
        this.loading = false
      }
    }
  }

}
</script>

<style scoped>

</style>